#!/bin/sh
#
#   Copyright (c) 2012 Denis Mingulov.
#
#   This file is part of Drop Cache.
#
#   This program is free software: you can redistribute it and/or modify
#   it under the terms of the GNU General Public License as published by
#   the Free Software Foundation, either version 3 of the License, or
#   (at your option) any later version.
#
#   This program is distributed in the hope that it will be useful,
#   but WITHOUT ANY WARRANTY; without even the implied warranty of
#   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#   GNU General Public License for more details.
#
#   You should have received a copy of the GNU General Public License
#   along with Drop Cache.  If not, see <http://www.gnu.org/licenses/>.

if test "x$1" = "x--1"; then
  echo 1 > /proc/sys/vm/drop_caches

elif test "x$1" = "x--2"; then
  echo 2 > /proc/sys/vm/drop_caches

elif test "x$1" = "x--3"; then
  echo 3 > /proc/sys/vm/drop_caches

else
  echo 'Usage:' $(basename $0) 'option'
  echo 'option is one of the following:'
  echo '--1                   free pagecache'
  echo '--2                   free dentries and inodes'
  echo '--3                   free pagescache, dentries and inodes'
exit 1
fi
